﻿using System;
using System.Text;
using System.Data;
using CRMFramework;

namespace CRMBiz
{
    public static class ExtraChecklistItemHandler
    {
        public static bool AddExtraChecklistItem(string ItemType, string ItemName, int app_id, string historyOperator)
        {
            bool flag = false;
            try
            {
                var para = new[] {
                    DBhelper.SetParameter("p_ItemType", ItemType),
                    DBhelper.SetParameter("p_ItemName", ItemName),
                    DBhelper.SetParameter("p_app_id", app_id),
                    DBhelper.SetParameter("hOperator",historyOperator),
                };

                //string sbSql = "insert into crm_extrachecklistitem(ItemType,ItemName) values(@ItemType,@ItemName)";
                DBhelper.ExecuteNonQuerySP("sp_AddExtraChecklistItem", para);
                flag = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return flag;
        }

        public static int getLastExtraChecklistItem()
        {
            int returnValue = 0;
            try
            {
                string sbSql = "select ExtraChecklistItemID from crm_extrachecklistitem order by ExtraChecklistItemID desc limit 1";
                DataTable dt = DBhelper.ExecuteDataset(sbSql).Tables[0];
                if (dt.Rows.Count > 0)
                    returnValue = int.Parse(dt.Rows[0]["ExtraChecklistItemID"].ToString());
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return returnValue;
        }
    }
}
